<?php
use yii\widgets\LinkPager;
use yii\helpers\Url;
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Json;
use backend\assets\AppAsset;
use yii\web\View;
?>
<style>
    .content{ border: 1px solid #eee; width: 100%; padding: 10px;margin-bottom: 20px;margin-top: 10px;}
    .child{ border: 1px solid #eee; width: 50%; padding: 10px;margin-bottom: 20px; height: 40px; margin-top: 10px;}
    .child .child_body{width: 100px; float: left; margin-right: 20px}
</style>
<div class="ibox-title">
	<h5>添加角色</h5>
</div>
<div class="ibox-content timeline">
    <div class="auth-item-model-form">
        <?php $form = ActiveForm::begin(['action' => ['item/addsetrole'], 'method' => 'post']); ?>
        <?= $form->field($model, 'name')->textInput(['maxlength' => true, 'disabled' => true])?>
        <input type="hidden" value="<?= $model['name']; ?>" name="name">
        <b>权限分配</b>
        <div class="content">
            <?php foreach($roule_data_arr as $val){ ?>
                <input type="checkbox" <?= in_array($val['name'], $roule_node)?  'checked = "checked"': '';?> name="node[]<?= $val['name']?>" value="<?= $val['name']?>"><?= $val['description'] ?>
                <?php if(isset($val['child']) && is_array($val['child'])): ?>
                <div class="child">
                    <?php foreach($val['child'] as $v): ?>
                    <div class="child_body">
                            <input type="checkbox" <?= in_array($v['name'], $roule_node)?  'checked = "checked"': '';?> name="node[]<?= $v['name']?>" value="<?= $v['name']?>"><?= $v['description'];?>
                    </div>
                    <?php endforeach; ?>
                </div>
                <?php endif; ?>
            <?php } ?>           
        </div>

        <div class="form-group">
            <?= Html::submitButton('保存', ['class' =>  'btn btn-primary green']) ?>
        </div>
        <?php ActiveForm::end(); ?>
    </div>
</div>